<!DOCTYPE html>
<title>Element#requestFullscreen() when not allowed to request fullscreen</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
async_test(t => {
  const div = document.querySelector("div");
  var promise_executed = false;

  document.addEventListener("fullscreenerror", t.step_func_done(event => {
    assert_equals(event.target, div, "event.target");
    assert_true(event.bubbles, "event.bubbles");
    assert_false(event.cancelable, "event.cancelable");
    assert_true(event.composed, "event.composed");
    assert_true(promise_executed, "promise executed");
  }));

  var promise = div.requestFullscreen();
  if (promise) {
    promise.catch(()=> {
      promise_executed = true;
    });
  } else {
    // If promises aren't supported just treat it as already done.
    promise_executed = true;
  }
});
</script>
